﻿using static System.Console;

/*
 * 多播委托
 */


int num = 10;

// 创建委托实例
NumberChanger nc;
NumberChanger nc1 = AddNum;
NumberChanger nc2 = MultNum;
nc = nc1;
nc += nc2;

// 移除委托
nc -= nc1;

// 调用多播
nc(5);
WriteLine($"Value of Num:{GetNum()}");

int AddNum(int p)
{
    num += p;
    return num;
}

int MultNum(int p)
{
    num *= p;
    return num;
}

int GetNum()
{
    return num;
}

ReadLine();

delegate int NumberChanger(int n);